#!/usr/bin/perl -w
#-----------------------------------------------------------+
#                                                           |
# DROP FASTA EXTENSION                                      |
#                                                           |
#-----------------------------------------------------------+
#  AUTHOR: James C. Estill                                  |
# CONTACT: jestill_at_sourceforge.net                       |
# STARTED: 05/23/2006                                       |
# UPDATED: 05/23/2006                                       |
#                                                           |
# DESCRIPTION:                                              |
# Drop suffix from a series of files in a dir. Written to   |
# drop the fasta extension from a series of files.          |
#                                                           |
# USAGE:                                                    |
#                                                           |
#-----------------------------------------------------------+

print "The program has started\n";

#-----------------------------+
# INCLUDES                    |
#-----------------------------+
use Term::ANSIColor;

#-----------------------------+
# LOCAL VARIABLES             |
#-----------------------------+
my $NumFiles = "37";
my $BaseDir = "/home/jestill/hmpr_msll/bacs/zm_chr09_supercontig/".
    "masked/";
my $Pre = "AllRep_Ch09_frag_";
my $NewPre = "Ch09_frag_";
my $Suf = ".masked";
#my $Suf = ".fasta";
my ( $SrcFile, $NewFile, $MvCmd );

for ( $i = 1; $i<=$NumFiles; $i++ )
{

    $SrcFile = $BaseDir.$Pre.$i.$Suf;
    #$NewFile = $BaseDir.$Pre.$i;
    $NewFile = $BaseDir.$NewPre.$i;
    $MvCmd = "mv $SrcFile $NewFile";
    print "SRC:\t$SrcFile\nDES\t$NewFile\n";
    if (-e $SrcFile)
    {
	system ($MvCmd)
    }else{
	print color 'red';
	print "\tCan not find:\n\t$SrcFile\n";
	print color 'reset';
    }
    
}

exit;


#-----------------------------------------------------------+
# SUBFUNCTIONS                                              |
#-----------------------------------------------------------+


#-----------------------------------------------------------+
# HISTORY                                                   |
#-----------------------------------------------------------+
#
# 05/23/2006
# - Program started. Just to work with numerical files
